﻿using System;

namespace DBUtil
{
    /// <summary>
    /// 当前数据库行为规则
    /// </summary>
    public class DBSettings : ICloneable
    {
        /// <summary>
        /// 默认的配置
        /// </summary>
        public static DBSettings Default = new DBSettings() { };

        /// <summary>
        /// 基于数据库的Id生成控制的存储过程名称,默认为"__proc_generateid"
        /// </summary>
        public string DBCacheGeneratorIdProcedureName { get; private set; } = "__proc_generateid";

        /// <summary>
        /// 基于数据库的Id生成控制的表名称,默认为"__generator_id"
        /// </summary>
        public string DBCacheGeneratorIdTableName { get; private set; } = "__generator_id";

        /// <summary>
        /// 基于数据库的Id生成控制的日志表名称,默认为"__generator_err_log"
        /// </summary>
        public string DBCacheGeneratorLogTableName { get; private set; } = "__generator_err_log";

        /// <summary>
        /// 基于数据库的流水号生成控制的存储过程名称,默认为"__proc_generatesno"
        /// </summary>
        public string DBCacheGeneratorSNOProcedureName { get; private set; } = "__proc_generatesno";

        /// <summary>
        /// 基于数据库的流水号生成控制的表名称,默认为"__generator_sno"
        /// </summary>
        public string DBCacheGeneratorSNOTableName { get; private set; } = "__generator_sno";

        /// <summary>
        /// 基于数据库的分布式锁使用的表名称,默认为"__db_lock"
        /// </summary>
        public string DBLockTableName { get; private set; } = "__db_lock";

        /// <summary>
        /// 是否对用户的输入进行参数化处理，默认为: false
        /// </summary>
        public bool UseParameter { get; private set; } = false;

        /// <summary>
        /// 克隆一个配置对象
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return new DBSettings()
            {
                DBCacheGeneratorIdProcedureName = DBCacheGeneratorIdProcedureName,
                DBCacheGeneratorIdTableName = DBCacheGeneratorIdTableName,
                DBCacheGeneratorLogTableName = DBCacheGeneratorLogTableName,
                DBCacheGeneratorSNOProcedureName = DBCacheGeneratorSNOProcedureName,
                DBCacheGeneratorSNOTableName = DBCacheGeneratorSNOTableName,
                DBLockTableName = DBLockTableName,
                UseParameter = UseParameter
            };
        }
    }
}
